const paginationBeh = Behavior({
    data: {
        dataArray: [],
        total: 0,
        noneResult: false,
    },

    methods: {
        setMoreData(dataArray) {
            const tempArray = [...this.data.dataArray, ...dataArray]
            this.setData({
                dataArray: tempArray
            })
        },
        getCurrentStart() {
            return this.data.dataArray.length
        },
        setTotal(total) {
            this.data.total = total
            if (total == 0) {
                this.setData({
                    noneResult: true
                })
            }
        },
        hasMore() {
            return this.data.dataArray.length < this.data.total
        },
        initialize() {
            this.setData({
                dataArray: [],
                noneResult: false,
                loading: false,
            })
            this.data.total = 0
        },
        locked() {
          this.setData({
            loading: true
          })
        },
        unLocked() {
          this.setData({
            loading: false
          })
        }
    }
})
export { paginationBeh }